package com.binhthuan.catechist.client.form;

import com.binhthuan.catechist.client.ECApplication;
import com.binhthuan.catechist.client.data.CourseDS;
import com.binhthuan.catechist.shared.constant.Parameter;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;

public class CourseForm extends AbstractForm {

    public CourseForm() {
    }

    public CourseForm(CourseDS dataSource) {
        super(dataSource);
        setMargin(10);
        setNumCols(4);
        setCellPadding(5);

        HiddenItem idField = new HiddenItem(Parameter.ID);
        
        TextItem codeField = new TextItem(Parameter.CODE);
        codeField.setTitle(ECApplication.getConstants().courseCode());
        codeField.setWrapTitle(false);
        codeField.setWidth(250);

        TextItem nameField = new TextItem(Parameter.NAME);
        nameField.setTitle(ECApplication.getConstants().name());
        nameField.setWrapTitle(false);
        nameField.setWidth(250);

        SelectItem yearField = new SelectItem(Parameter.YEAR);
        yearField.setTitle(ECApplication.getConstants().schoolYear());
        yearField.setWrapTitle(false);
        yearField.setWidth(250);

        SelectItem gradeField = new SelectItem(Parameter.GRADE);
        gradeField.setTitle(ECApplication.getConstants().grade());
        gradeField.setWrapTitle(false);
        gradeField.setWidth(250);

        SelectItem shiftField = new SelectItem(Parameter.SHIFT);
        shiftField.setTitle(ECApplication.getConstants().shift());
        shiftField.setWrapTitle(false);
        shiftField.setWidth(250);

        SelectItem venueField = new SelectItem(Parameter.VENUE);
        venueField.setTitle(ECApplication.getConstants().venue());
        venueField.setWrapTitle(false);
        venueField.setWidth(250);
        /*
        SelectItem trainersField = new SelectItem(Parameter.TRAINERS);
        trainersField.setTitle(ECApplication.getConstants().trainer());
        trainersField.setWrapTitle(false);
        trainersField.setColSpan(4);
*/
        ButtonItem saveButton = createSaveButton();
        saveButton.setColSpan(4);

        setFields(idField, codeField, nameField, yearField, gradeField, shiftField, venueField, saveButton);
    }
}
